package cn.fl.customer.service.impl;

import java.util.List;

import fl.customer.facade.invoice.api.IInvoiceApiService;
import fl.customer.facade.invoice.condition.SearchValidInvoiceQueryCondition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.customer.service.IPrjBillFeeRService;
import cn.fl.customer.transform.PrjBillFeeRVOTransform;
import cn.fl.customer.vo.PrjBillFeeRVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import fl.customer.facade.invoice.api.ICustInvoiceApiService;
import fl.customer.facade.invoice.condition.PrjBillFeeRQueryCondition;
import fl.customer.facade.invoice.dto.PrjBillFeeRDTO;

/**
 * @Description: 票据-费用关系表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class PrjBillFeeRServiceImpl implements IPrjBillFeeRService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(IPrjBillFeeRService.class);
	
	/**
	 * 发票服务
	 */
	@Autowired
	private ICustInvoiceApiService custInvoiceApiService;

	@Autowired
    private IInvoiceApiService invoiceApiService;

	@Override
	public PrjBillFeeRVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "selectById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		//TODO 业务逻辑
		PrjBillFeeRDTO dto = null;//this.自定义ApiService.selectById(id);
		return PrjBillFeeRVOTransform.toVO(dto);
	}

	@Override
	public Long add(PrjBillFeeRVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "对象不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		//return this.prjBillFeeRApiService.add(PrjBillFeeRVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return null;
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		return this.custInvoiceApiService.removeBillFeeRById(id);
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
    		BaseLogUtils.info(logger, "removeByIds", "主键参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		};
		return false;
    }

	@Override
	public boolean modify(PrjBillFeeRVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "modify", "对象参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		//return this.prjBillFeeRApiService.modify(PrjBillFeeRVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return false;
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		//return this.prjBillFeeRApiService.searchListPage(page);
		//TODO 业务逻辑
		return null;
	}

	@Override
	public List<PrjBillFeeRVO> searchList(PrjBillFeeRQueryCondition qc) throws BaseException {
		if(null == qc){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "查询对象不能为空!");
		}
		List<PrjBillFeeRDTO> resultList = this.custInvoiceApiService.searchBillFeeRList(qc);
		return PrjBillFeeRVOTransform.toVOList(resultList);
	}

	@Override
	public boolean removeToHoldById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeToHoldById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		return this.custInvoiceApiService.removeBillFeeRToHoldById(id);
	}

	@Override
	public boolean modifyHoldToNormalById(Long id) throws BaseException {
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "modifyHoldToNormalById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		return this.custInvoiceApiService.modifyHoldToNormalById(id);
	}

    @Override
    public List<PrjBillFeeRVO> searchBillFeeListByApplyId(SearchValidInvoiceQueryCondition condition) throws BaseException {
        return PrjBillFeeRVOTransform.toVOList(this.invoiceApiService.searchBillFeeListByApplyId(condition));
    }
}
